import { createRouter, createWebHistory } from 'vue-router'
import { constantRoutes } from './constantRoutes'

export const routes = [
  {
    path: '/',
    redirect: '/dashboard'
  },
  {
    path: '/layout',
    name: 'layout',
    component: () => import('@/layout/index.vue'),
    children: [
      {
        path: '/dashboard',
        name: 'dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: {
          title: '首页'
        }
      },
      {
        path: '/system',
        name: 'system',
        children: [
          {
            path: '/system/user',
            name: 'systemUser',
            component: () => import('@/views/system/user/index.vue'),
            meta: {
              title: '用户管理'
            }
          },
          {
            path: '/system/role',
            name: 'systemRole',
            component: () => import('@/views/system/role/index.vue'),
            meta: {
              title: '角色管理'
            }
          },
          {
            path: '/system/menu',
            name: 'systemMenu',
            component: () => import('@/views/system/menu/index.vue'),
            meta: {
              title: '菜单管理'
            }
          }
        ]
      }
    ]
  },

  ...constantRoutes
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
